/**
 * *******************************************
 * user: zmq
 * describe: 账号表数据库操作
 * created:
 * date: 2021/8/18
 * *******************************************
 */

import {pinus, FrontendSession} from "pinus";
import Utils from "../../util/utils";

export default class AccountDao {

    /**
     * 获取账号信息
     * @param account
     * @returns {Promise<any>}
     */
    public static getAccount(account: string): Promise<any> {

        let sql = 'select * from account where account = ?  ';
        let args = [account];


        // rpc调用dao服务器 操作数据库
        let serverID = pinus.app.getServerId();
       return  pinus.app.rpc.dao.daoRemote.query({ serverID: serverID }, sql, args);
    }

    /**
     * 获取账号信息
     * @param account
     * @param pwd
     * @returns {Promise<any>}
     */
    public static addAccount(account: string, pwd: string): Promise<any> {

        let createTime = Utils.getCurTime();
        let sql = 'insert into account(account,pwd,createTime) values(?,?,?);';
        let args = [account, pwd, createTime];

        // rpc调用dao服务器 操作数据库
        let serverID = pinus.app.getServerId();
        return  pinus.app.rpc.dao.daoRemote.query({ serverID: serverID }, sql, args);
    }
}

